package com.disease.chronic.Service.Impl;

import com.disease.chronic.Exception.ChronicExceptionEnum;
import com.disease.chronic.Global.Result;
import com.disease.chronic.Mappers.TipsMapper;
import com.disease.chronic.Service.TipsService;
import com.disease.chronic.pojo.Tips;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TipsServiceImpl implements TipsService {


    @Autowired
    TipsMapper tipsMapper;


    @Override
    public Result getTips() {
        List<Tips> tips = tipsMapper.selectAll();
        int num = (int)(Math.random()*tips.size()) ;

        return new Result(ChronicExceptionEnum.SUCCESS.getCode(),
                ChronicExceptionEnum.SUCCESS.getMessage(),
                tips.get(num));
    }
}
